﻿using AutoMapper;
using System;
using System.Collections.Generic;
using System.Text;

namespace StudentManagement.Tools
{
    public class AutoMapperHelp
    {
        /// <summary>
        /// 类型转换
        /// </summary>
        /// <typeparam name="TSource"></typeparam>
        /// <typeparam name="TDestination"></typeparam>
        /// <param name="source"></param>
        /// <returns></returns>
        public static TDestination Map<TSource, TDestination>(TSource source)
        {
            var autoMap = new Mapper(new MapperConfiguration(configure =>
            {
                configure.CreateMap<TSource, TDestination>();
            }));
            return autoMap.Map<TSource, TDestination>(source);
        }
    }
}
